home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Varsity Update 1998 August
/
SGI Varsity Update 1998 August.iso
/
dist
/
dist6.5
/
il_dev.idb
/
usr
/
include
/
il
/
ilView.h.z
/
ilView.h
Wrap
C/C++ Source or Header
|
1998-07-29
|
18KB
|
615 lines
#if 0
Copyright (c) 1991 SGI All Rights Reserved
THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
The copyright notice above does not evidence any
actual or intended publication of such source code,
and is an unpublished work by Silicon Graphics, Inc.
This material contains CONFIDENTIAL INFORMATION that
is the property of Silicon Graphics, Inc. Any use,
duplication or disclosure not specifically authorized
by Silicon Graphics is strictly prohibited.
RESTRICTED RIGHTS LEGEND:
Use, duplication or disclosure by the Government is
subject to restrictions as set forth in subdivision
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 52.227-7013, and/or in similar
or successor clauses in the FAR, DOD or NASA FAR
Supplement. Unpublished- rights reserved under the
Copyright Laws of the United States. Contractor is
SILICON GRAPHICS, INC., 2011 N. Shoreline Blvd.,
Mountain View, CA 94039-7311
#endif
/*
ilView contains the state of a view such as position within the ilDisplay,
position within the ilImage and current size of the view.
*/
#ifndef _ilView_h_
#define _ilView_h_
#include <X11/Xlib.h>
#include <il/ilLink.h>
#include <il/ilImage.h>
#include <il/ilIndexableList.h>
#include <il/ilDisplayDefs.h>
//
// ilView Enumerated Types
//
// ilView border styles
enum ilViewBorderStyle {
ilViewBdrSolidLines = 0, // Solid lines (old style)
ilViewBdrDashedLines = 1, // Dashed lines
ilViewBdrCornerHandles = 2, // Handles on corners
ilViewBdrMiddleHandles = 3 // Handles on mid-side (slow wipe)
};
// ilView state
enum ilViewState {
ilViewAnyState = 1 << 0,
ilViewMovedView = 1 << 1,
ilViewMovedImg = 1 << 2,
ilViewResized = 1 << 3,
ilViewExposed = 1 << 4,
ilViewBorders = 1 << 5
};
// ilView Callbacks (see bottom)
enum ilViewCb {
ilViewPostRenderCb = 1,
ilViewBorderRenderCb = 2,
ilViewAllCb = 3
};
// ilView stereo pair identifiers
enum ilViewImgPairIdx {
ilViewImgPairLeft = 0,
ilViewImgPairRight = 1
};
class ilViewColor {
public:
float red, green, blue;
int index;
void get(float& Red, float& Green, float& Blue)
{ Red = red; Green = green; Blue = blue; }
void set(float Red, float Green, float Blue)
{ red = Red; green = Green; blue = Blue; index = -1; }
int getIndex() { return index; }
void setIndex(int Index) { index = Index; }
void invalidateIndex()
{ index = -1; }
int isValidIndex()
{ return index >= 0; }
};
// Queued view tile to paint
class ilViewQTile : public ilLinkItem
{
public:
ilViewQTile()
{ tile.x = tile.y = tile.nx = tile.ny = 0; mode = 0; }
ilViewQTile(const iflTile2D<int>& t, int m)
{ init(t, m); }
~ilViewQTile() {}
void init(const iflTile2D<int>& t, int m)
{ mode = m;
tile.x = t.x; tile.y = t.y;
tile.nx = t.nx; tile.ny = t.ny;
}
iflTile2D<int> tile;
int mode;
};
class ilDisplayMgr;
// ilView is a sub-region of an ilDisplay. It is used to view
// part of an image on the screen. It is managed by ilDisplay.
//
class ilView : public ilLink, public ilLinkItem {
public:
iflClassListDeclare
friend class ilDisplay;
friend class ilViewCbArg;
~ilView();
// external api: begin
ilView(ilDisplay* disply, ilImage* img, int mode = 0);
// external api: name=ilViewDisp
ilView(ilDisplay* disply); // XXX is this useful ???
ilDisplay* getDisplay() { return disp; }
// View configuration
void getPos(int& x, int& y);
void getSize(int& x, int& y);
virtual void getImgPos(float& x, float& y, unsigned imgIdx = 0);
virtual void getImgSize(int& x, int& y, unsigned imgIdx = 0);
// external api: name=getImgPos3D
virtual void getImgPos(float& x, float& y, float& z, unsigned imgIdx = 0);
// external api: name=getImgSize3D
virtual void getImgSize(int& x, int& y, int& z, unsigned imgIdx = 0);
float getZ() { return iPos.z; }
void setZ(float z);
virtual void setImg(ilImage* ilInImg, unsigned imgIdx = 0);
virtual ilImage* getImg(unsigned imgIdx = 0);
const char* getName(int flags=0);
void setNop(int noOp) { nop = noOp; }
int isNop() { return nop == 0? FALSE : TRUE; }
void setDefer(int defer);
int isDefer() { return defer == 0 ? FALSE:TRUE; }
void getPixel(int x, int y, iflPixel& pix, int mode = 0,
unsigned imgIdx = 0);
void setPixel(int x, int y, iflPixel& pix, int mode = 0,
unsigned imgIdx = 0);
// XXX allow space for ix,iy and space for returned x,y ???
// Return window location (x,y) at image location (ix,iy)
void getImgLoc(float ix, float iy, float& x, float& y,
int mode = ilLocIn,
iflOrientation orientation = iflOrientation(0),
unsigned imgIdx = 0);
// Return image location (ix,iy) at window location (x,y)
void getLoc(float x, float y, float& ix, float& iy,
int mode = ilLocIn,
iflOrientation orientation = iflOrientation(0),
unsigned imgIdx = 0);
// external api: name=getLocMode
void getLoc(float& ix, float& iy, int mode = ilLocIn|ilCenter,
iflOrientation orientation = iflOrientation(0),
unsigned imgIdx = 0);
// Set image location (ix,iy) to window location (x,y)
void setLoc(float ix, float iy, float x, float y,
int mode = ilLocIn,
iflOrientation orientation = iflOrientation(0),
unsigned imgIdx = 0);
// external api: name=setLocMode
void setLoc(float ix, float iy, int mode = ilLocIn|ilCenter,
iflOrientation orientation = iflOrientation(0),
unsigned imgIdx = 0);
void setAutoCenter(int enable=TRUE);
int isAutoCentered() { return autoCenter; }
int findEdge(int x, int y, int margin = -1, int mode = ilDspCoord);
void getBackground(float& red, float& green, float& blue)
{ back.get(red, green, blue); }
void setBackground(float red, float green, float blue)
{ back.set(red, green, blue); }
void getErrorColor(float& red, float& green, float& blue)
{ err.get(red, green, blue); }
void setErrorColor(float red, float green, float blue)
{ err.set(red, green, blue); }
int isStaticUpdate() { return staticUpdate || autoStaticUpdate; }
void setStaticUpdate(int enable) { staticUpdate = enable; }
void setAutoStaticUpdate(int enable) { autoStaticUpdate = enable; }
void select();
void unselect();
int isSelected();
virtual int isStereoView();
// Callback Setup
// NOTE that prepare and/or finish callbacks may be NULL
void setCallback(ilCallback* prepare,
ilCallback* render,
ilCallback* finish = NULL)
{
postPrepareCB = prepare;
postRenderCB = render;
postFinishCB = finish;
}
void setBorderCallback(ilCallback* prepare,
ilCallback* render,
ilCallback* finish = NULL)
{
borderPrepareCB = prepare;
borderRenderCB = render;
borderFinishCB = finish;
}
void getCallback(ilCallback*& prepare,
ilCallback*& render,
ilCallback*& finish)
{
prepare = postPrepareCB;
render = postRenderCB;
finish = postFinishCB;
}
void getBorderCallback(ilCallback*& prepare,
ilCallback*& render,
ilCallback*& finish)
{
prepare = borderPrepareCB;
render = borderRenderCB;
finish = borderFinishCB;
}
void addPreRenderCallback(ilCallback* cb);
ilStatus removePreRenderCallback(ilCallback* cb);
// Callback Enable/Disable
void enableCallback(int enable = TRUE)
{ enableCB(ilViewPostRenderCb, enable); }
void enableBorderCallback(int enable = TRUE)
{ enableCB(ilViewBorderRenderCb, enable); }
int isCallbackEnabled()
{ return isCBEnabled(ilViewPostRenderCb); }
int isBorderCallbackEnabled()
{ return isCBEnabled(ilViewBorderRenderCb); }
// Border stuff
int getBorderStyle() { return bStyle; }
void setBorderStyle(int style = ilViewBdrSolidLines)
{ bStyle = style; setState(ilViewBorders); }
int getBorderWidth() { return bWidth; }
void setBorderWidth(int bordWidth)
{ bWidth = bordWidth; setState(ilViewBorders); }
void getBorderColor(float& red, float& green, float& blue)
{ border.get(red, green, blue); }
void setBorderColor(float red, float green, float blue)
{ border.set(red, green, blue); setState(ilViewBorders); }
void setBorders(int flag, int mode = ilDefault);
int hasBorders() { return borders != 0; }
// Get 4 tiles that makeup borders (unclipped)
void getBorders(iflTile2Dint& top, iflTile2Dint& bot,
iflTile2Dint& lf, iflTile2Dint& rt,
iflOrientation orientation);
// Display operators
// Move view in display
void moveView(int x, int y, int mode = ilRelVal);
// Move image in view
void moveImg(float x, float y, int mode = ilRelVal);
// Move one or more edges of view
void wipe(int x, int y, int mode = ilRelVal);
// Resize view by wiping edge/corner and opposite edge/corder
void wipeSize(int x, int y, int mode = ilDelVal | ilTopRight);
// Wipe nearest edge on all views
void wipeSplit(int x, int y, int mode = ilRelVal);
// Resize and move views so all visable
void split(int mode = ilAbsSplit|ilRowSplit|ilColSplit);
// Align image within a view
void alignImg(int mode = ilCenter);
// Align view to a reference view
void alignView(int mode = ilCenter, ilView* rView = NULL);
// Update view position/size and position of image
void update(int x = 0, int y = 0, int nx = 0, int ny = 0,
float imgX = 0, float imgY = 0, int mode = ilDelVal);
// Paint damaged regions of view
void paint(int mode = 0)
{ qPaint(NULL, mode); }
// Queue damaged regions of view to be painted
void qPaint(ilMpNode* parent, int mode = 0,
ilMpManager** pMgr = NULL);
// Re-initialize view
void display(int vMode =ilCenter, int iMode =ilCenter);
// Resize view based on image size and mode
void resize(int mode = 0);
// Save view
ilStatus save(ilImage* img, int mode = 0);
// indicate view needs to be repainted for some external reason
// (like graphics drawn on top that need to be updated)
//
void setDirty();
// controls display of images with alpha, if
void showTransparency(int enable=TRUE);
int isTransparencyShown();
// external api: end
#if defined(IL2_5_COMPAT)
void getImgPos(int& x, int& y)
{
float xf, yf;
getImgPos(xf, yf);
x = xf;
y = yf;
}
void getLoc(int x, int y, int& ix, int& iy, int mode = ilLocIn)
{
float xf = x, yf = y, ixf, iyf;
getLoc(xf, yf, ixf, iyf, mode);
ix = ixf;
iy = iyf;
}
#endif
protected:
// file tile with error color
ilStatus qFillError(ilMpNode* parent, const iflTile2D<int>& tile,
int buffEnables=0)
{ return qFill(parent, tile, err, 0, buffEnables); }
// file tile with background color
ilStatus qFillBackground(ilMpNode* parent, const iflTile2D<int>& tile,
int mode=0, int buffEnables=0)
{ return qFill(parent, tile, back, mode, buffEnables); }
// file tile with border color
ilStatus qFillBorder(ilMpNode* parent, const iflTile2D<int>& tile,
int mode=0, int buffEnables=0)
{ return qFill(parent, tile, border, mode, buffEnables); }
// View configuration queries
void getImgSizeImg(ilImage* img, int& x, int& y, int& z);
virtual void reset();
virtual void alterAction();
ilDisplay* disp; // ilDisplay for this view
// render a mapped img tile into the view
// called by render()
virtual ilStatus qRenderTile(ilDisplayMgr* parent,
const iflTile2D<float>&,
const iflTile2D<int>& tile, int mode);
private:
// render a tile in the view
void qRender(ilDisplayMgr* parent, const iflTile2D<int>& tile, int mode);
// Add tile to list of view tiles to render
void addTile(const iflTile2D<int>& tile, int mode);
// Queue list of tiles to render
int queueImgTiles(ilDisplayMgr* parent);
int queueBorderTiles(ilDisplayMgr* parent);
int queueFillTiles(ilDisplayMgr* parent);
// Callback control
ilStatus doPreRenderCallbacks(ilMpManager* mgr);
void doPostRenderCallbacks();
void qPostRenderCallbacks(ilDisplayMgr* parent);
void doBorderCallbacks();
void qBorderCallbacks(ilDisplayMgr* parent);
void enableCB(int mask, int enable = TRUE);
int isCBEnabled(int mask)
{ return cbEnable & mask; }
int hasPostCallback()
{ return isCBEnabled(ilViewPostRenderCb) && postRenderCB; }
int hasBorderCallback()
{ return isCBEnabled(ilViewBorderRenderCb) && borderRenderCB; }
// paint or erase borders around view
virtual void paintBorders();
int needsPaint();
int isDirty();
int isBorderDirty();
void setBorderDirty();
void clearDirty(int mode=0);
// Get tile of current view position/size
void getTile(iflTile2D<int>& tile);
// Get tile of new view position/size
void getNewTile(iflTile2D<int>& tile);
// Move image in view
void moveImgIdx(float x, float y, unsigned int imgIdx, int mode);
// Get delta position, size and image position (since last paint)
void getDel(iflXYint& dVPos, iflXYint& dVSize, iflXYfloat& dIPos);
void getDel(iflXYint& dVPos, iflXYint& dVSize, iflXYZfloat& dIPos);
// Get callback deltas (snapshot of actual deltas)
void getCbDel(iflXYint& dVPos, iflXYint& dVSize, iflXYfloat& dIPos);
void getCbDel(iflXYint& dVPos, iflXYint& dVSize, iflXYZfloat& dIPos);
// Methods to get/set view state
void clrState() { vState = 0; needStatic = False; }
void setState(int state) { vState |= state; }
int getState() { return vState; }
int isState(int state) { return vState&state; }
int needStaticUpdate(); // Returns TRUE if whole img needs update
int isNewDataExposed(); // Returns TRUE if new img data exposed
void init(int mode);
void initSize(int mode);
void updateState();
// fill tile with specified color
ilStatus qFill(ilMpNode* parent,
const iflTile2D<int>& tile, ilViewColor& color,
int mode=0, int buffEnables=0);
void deleteList(ilIndexableList& list);
int hasDel();
int hasViewDel();
int hasLastDel();
int hasLastViewDel();
void applyDel();
void sumDel(const iflXYint& dVPos, const iflXYint& dVSize,
const iflXYfloat& dIPos);
void sumDelImgIdx(const iflXYfloat& dIPos, unsigned int imgIdx);
void clearDel();
void clearCbDel();
void clearLastDel();
void updateCbDel();
void getLastTile(iflTile2D<int>& tile);
void setLastDel(const iflXYint& dVPos, const iflXYint& dVSize,
const iflXYZfloat& dIPos);
void getLastDel(iflXYint& dVPos, iflXYint& dVSize, iflXYZfloat& dIPos);
void setEdge(int iedge) { edge = iedge; }
int getEdge() { return edge; }
inline int round(float val) { return val>0? int(val+0.5):int(val-0.5); }
void setSize(int x, int y);
void setPos(int x, int y);
void updateImgCenter();
void updateViewInfo();
void checkTransparency();
void cleanupTransparency();
ilIndexableList imgList; // List of image tiles to paint
ilIndexableList borderList; // List of border tiles to paint
ilIndexableList fillList; // List of fill tiles to paint
ilIndexableList freeList; // List of free ilViewQTile*'s
class ilBlendImg* blend; // used when showing transparency
iflXYZfloat iPos; // position of view within image
iflXYint vPos; // position of view within display
iflXYint size; // size of view
iflXYint dPos; // position of display on the screen
iflXYint delVSize; // Delta view size/position and img size.
iflXYint delVPos; // Used to defer display operations
iflXYZfloat delIPos;
iflXYint lastDelVSize; // Used to sync back to front
iflXYint lastDelVPos; // in double buffer mode
iflXYZfloat lastDelIPos;
iflXYint cbDelVPos; // Snap-shot of deltas for callbacks
iflXYint cbDelVSize;
iflXYZfloat cbDelIPos;
ilHwViewInfoHint viewInfo; // view info hint for draws
ilViewColor back; // background color
ilViewColor err; // error color
ilViewColor border; // border color
int bStyle; // border style (0/1 = lines/handles)
int bWidth; // border width
int borders; // border on (TRUE/FALSE)
int fDirty; // front buffer needs painting
int bDirty; // back buffer needs painting
int fBorderDirty; // front buffer border needs painting
int bBorderDirty; // back buffer border needs painting
int newDataExposed; // TRUE if new img data exposed (roam)
int needStatic; // if TRUE then need static update
int staticUpdate; // if TRUE then do static update always
int autoStaticUpdate; // if TRUE then do static update if needed
iflXYfloat iCenter; // center pixel of input image
int autoCenter; // if TRUE then track the image pixel in the
// center of the view and keep it there when
// the image is altered
int movedCenter; // if TRUE the image center has been changed
int vState; // State of ilView
int mode; // op mode
int defer; // defer painting this view
int nop; // op or nop on this view
char edge; // default edge
char showTrans; // are we showing transparency
char spare0; // XXX unused
char spare1;
int cbEnable; // Callback functions enabled
// Post rendering callback
ilCallback* postPrepareCB; // prepare for rendering
ilCallback* postRenderCB; // do actual rendering
ilCallback* postFinishCB; // finish rendering
// Border callbask
ilCallback* borderPrepareCB;// prepare for borders
ilCallback* borderRenderCB; // render borders
ilCallback* borderFinishCB; // finish for borders
ilCallbackList* preRenderCB;// callback to do any pre-rendering setup.
protected:
virtual void _updateImgCenter();
virtual void _recenter();
virtual void _updateDelImgPosIdx(unsigned int imgIdx, float dx, float dy);
virtual void _applyImgDel();
virtual void _clearImgDel();
virtual int _hasImgDel();
};
#endif